/*
 * @Descripttion: 
 * @version: 
 * @Author: sueRimn
 * @Date: 2022-10-09 10:38:23
 * @LastEditors: sueRimn
 * @LastEditTime: 2022-11-18 15:03:33
 */

let db = require("./index");

exports.add = (strSql, res) => {
  db.query(strSql, (err, data) => {
    if (err) {
      res.send({
        status: 0,
        message: "failed",
        data: err.message
      });
    } else {
      res.send({
        status: 1,
        message: "ok",
        data: {}
      })
    }
  })
}
exports.update = (strSql, res) => {
  db.query(strSql, (err, data) => {
    if (err) {
      console.log("err is ", err)
      res.send({
        status: 0,
        message: "failed",
        data: err.message
      });
    } else {
      res.send({
        status: 1,
        message: "ok",
        data: {}
      })
    }
  })
}
exports.delete = (strSql, res) => {
  db.query(strSql, (err, data) => {
    if (err) {
      res.send({
        status: 0,
        message: "failed",
        data: err.message
      });
    } else {
      res.send({
        status: 1,
        message: "ok",
        data: {}
      })
    }
  })
}
exports.search = (strSql, res) => {
  db.query(strSql, (err, data) => {
    if (err) {
      res.send({
        status: 0,
        message: "failed",
        data: err.message
      });
    } else {
      res.send({
        status: 1,
        message: "ok",
        data: data
      })
    }
  })
}